package com.maven.blog.service;


import com.maven.blog.mapper.BlogMapper;
import com.maven.blog.mapper.UserMapper;
import com.maven.blog.model.Blog;
import com.maven.blog.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserService {
    @Autowired
    UserMapper userMapper;
    @Autowired
    BlogMapper blogMapper;

    public User check(String userName, String password) {
        return userMapper.selectByName(userName);
    }

    public User getById(Integer id) {
        return userMapper.selectById(id);
    }

    public User getAuthorInfoByBlogId(Integer blogId) {
        Blog blog = blogMapper.selectById(blogId);
        return userMapper.selectById(blog.getUserId());
    }
}
